package com.ntd.study.algorithm.reduce.jzsf;

import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import com.ntd.study.algorithm.reduce.StudyReduceMes;

public class test2 {
    public static char[] NC= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()-=[];',./_+{}|:\"<>?".toCharArray();

    public static void main(String[] args) {
        Console.log(NC.length);
        final Integer ffff = Integer.valueOf("ff", 16);
        Console.log(strTohex(StrUtil.removeAllLineBreaks(StudyReduceMes.mes)));
    }

    public static String strTohex(String str){
        String res = "";
        for (int i = 0; i < str.length(); i = i + 2) {
            String substring = null;
            try {
                substring = str.substring(i, i + 2);
            } catch (Exception e) {
                substring = str.substring(i);
            }
            final Integer integer = Integer.valueOf(substring, 16);
            res += (char) integer.intValue();
        }
        if (str.length() % 2 == 1) {
            final Integer integer = Integer.valueOf(str.substring(str.length() - 1), 16);
            res = res + ((char) integer.intValue());
        }
        return res;
    }
}
